﻿/******************************************************************************
 * 【本类功能概述】                                 					      *
 *  版权所有（C）2017-20XX，梦匠科技                                          *
 *  保留所有权利。                                                            *
 ******************************************************************************
 *  作者 : <PC-shijiankai>
 *****************************************************************************/
using UnityEngine;
using System.Collections.Generic;
namespace CSV
{
/// <summary>
/// 行为表
/// </summary>
public class Behaviors
{
	private volatile static CSVReader _instance = null;
    private static readonly object lockHelper = new object();
	/// <summary>
	/// 行为表
	/// </summary>
	public const string _id="id";
	/// <summary>
	/// 类型(1待机2移动3攻击4技能5建造)
	/// </summary>
	public const string _type="type";
	/// <summary>
	/// 说明
	/// </summary>
	public const string _explain="explain";
	/// <summary>
	/// cd
	/// </summary>
	public const string _CD="CD";
	/// <summary>
	/// 所属菜单
	/// </summary>
	public const string _menu="menu";
	/// <summary>
	/// 执行消息
	/// </summary>
	public const string _Message="Message";

	public class line
    {
		/// <summary>
		/// 行为表
		/// </summary>
		public int id;
		/// <summary>
		/// 类型(1待机2移动3攻击4技能5建造)
		/// </summary>
		public int type;
		/// <summary>
		/// 说明
		/// </summary>
		public string explain;
		/// <summary>
		/// cd
		/// </summary>
		public float CD;
		/// <summary>
		/// 所属菜单
		/// </summary>
		public int menu;
		/// <summary>
		/// 执行消息
		/// </summary>
		public int Message;

    }
    private static Dictionary<string, line> m_datadic = new Dictionary<string, line>();
    public static line getline(string id)
    {
        if (m_datadic.ContainsKey(id))
        {
            return m_datadic[id];
        }
        else
        {
            line _line = new line();
			_line.id = Instance().getintById(id, _id);
			_line.type = Instance().getintById(id, _type);
			_line.explain = Instance().getstringById(id, _explain);
			_line.CD = Instance().getfloatById(id, _CD);
			_line.menu = Instance().getintById(id, _menu);
			_line.Message = Instance().getintById(id, _Message);

            m_datadic.Add(id, _line);
            return _line;
        }
    }
	
	public static CSVReader Instance()
	{
        if(_instance == null)
        {
            lock(lockHelper)
            {
                if(_instance == null)
                     _instance = ConfigManager.GetCsvData("Behaviors");
            }
        }
        return _instance;
    }
}
}